home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-23 | 5.0 KB | 113 lines | [TEXT/KAHL] |
- typedef short BOOL;
- typedef BOOL (*funptr) ();
- typedef struct expr *EXPR;
-
- /* ---------- control routines ---------------------------- */
-
- extern void AddXfun(char *name,char *parms,funptr entry,void (*predef)(),funptr callback);
- /* Install a new function. */
-
- extern void AddFunDim(char *name,long lim,funptr callback);
- /* Setup routine to allow the XFun to return values based on the array index.
- This routine must be called by the predef routine. It can be called multiple times
- to set up a multidimensional return value. Array index values are appended to the
- parameter list */
-
- extern void ErrMsg(char *fmt,char *str,funptr callback);
- /* Show an error message in the status line.
- fmt is a printf() format string. str is an optional parameter
- Sets stop flag to tell MathPad to stop all evaluation. */
-
- extern BOOL Stopped(funptr callback);
- /* Check value of stop flag to see if evaluation should be stopped. */
-
- extern void SpinWatch(funptr callback);
- /* Allow a computation to be switched to background or stopped via command period.
- Stopped() must be checked to see if command period was hit.
- SpinWatch() should be called at least twice per second.
- It can be called at a much higher rate without much loss. */
-
- extern void SetPlotPICT(PicHandle thePic,funptr callback);
- /* Replace any pasted PICT with thePic. Allows XFun to place graphics on the plot */
-
-
- /* ------------- function parameter access ---------------- */
- /* Parameters are numbered from right to left starting at 0 */
-
- extern BOOL GetParmVal(long n,extended *num,funptr callback);
- /* Get the value of a simple numeric parameter.
- Returns false if the value is an array or undefined */
-
- extern void MakeParmExpr(long n,EXPR *xpr,funptr callback);
- /* Make a parameter expression. (Used to access arrays).
- The expression must be deallocated with FreeExpr(xpr). */
-
- extern BOOL GetParmName(long n,char **name,funptr callback);
- /* Get a name parameter. (Used to get a filename or other string).
- Returns false if the parameter was an expression or defined variable */
-
-
-
- /* ------------------ global variable access ---------------- */
-
- extern BOOL GetVarVal(char *name,extended *num,funptr callback);
- /* Evaluate the named global variable.
- Returns false if the value is an array or undefined */
-
- extern void GetVarString(char *name,char **str,funptr callback);
- /* Returns the string value of a named global variable.
- Returns an empty string if unless the variable was set to a string */
-
- extern void MakeVarExpr(char *name,EXPR *xpr,funptr callback);
- /* Make a global variable expression. (Used to access arrays).
- The expression must be deallocated with FreeExpr(xpr). */
-
- extern BOOL SetVarVal(char *name,extended num,funptr callback);
- /* Assign a single value to the named global variable.
- Returns false if the variable is an illegal destination. */
-
- extern BOOL SetVarMatrix(char *name,extended *arr,long rows,long cols,funptr callback);
- /* Assign a 1D or 2D array to the named global variable.
- Returns false if the variable is an illegal destination.
- The array must be allocated via NewPtr() and will be deallocated by MathPad. */
-
- extern void FoldVar(char *name,long lim,funptr callback);
- /* Add a dimension to the variable set by SetVarMatrix(). Can be called multiple
- times to create more dimensions. */
-
-
-
- /* ------------ general expression routines ----------------- */
-
- extern BOOL GetExprMatrix(EXPR xpr,extended **mat,long *rows,long *cols,funptr callback);
- /* Allocate memory and evaluate all elements of a 1D or 2D matrix expression into memory.
- Returns a pointer to the matrix in mat.
- A scalar will return cols=0 and rows=0. A 1D array will return cols=0.
- An array with more than 2 dimensions will generate an error message and return false.
- The matrix allocated by GetExprMatrix() should be deallocated with DisposPtr() */
-
- extern BOOL ProbeExpr(EXPR xpr,extended *num,BOOL *isarray,long *count,funptr callback);
- /* Find out if an expression is a scalar or an array.
- If scalar, returns true and sets num.
- If array, returns false and sets isarray and count. A count of 0 means infinite array.
- If the return value and isarray are both false the expression was undefined. */
-
- extern void AddIndex(EXPR *xpr,extended **iptr,funptr callback);
- /* Add an index to allow evaluating individual array elements.
- The extended at iptr can be modified to index through the array.
- To access a single element, an index must be added for each dimension of the array. */
-
- extern void RemoveIndex(EXPR *xpr,funptr callback);
- /* Remove an index. RemoveIndex() should only be used on an expression that was previously
- modified by AddIndex(). Normally FreeExpr() is be used to free the entire expression so
- this call is not required. */
-
- extern BOOL EvalExpr(EXPR xpr,extended *num,funptr callback);
- /* Evaluate an expression. Returns false if xpr is an array or undefined */
-
- extern void FreeExpr(EXPR xpr,funptr callback);
- /* Free memory allocated to an expression.
- Use to deallocate from MakeParmExpr() or MakeVarExpr() */
-
-
-